# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=python2-requests
_pkgname=requests
pkgver=2.26.0
pkgrel=2
pkgdesc='Python HTTP for Humans.'
url='https://pypi.org/project/requests/#files'
arch=('any')
license=('Apache')
depends=('python2' 'python2-urllib3' 'python2-chardet' 'python2-idna')
makedepends=('python2-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
        'certs.py.patch')
sha512sums=('c3397d77f0d2f1afb05661c4b98adad6c1ddaf360906254150b33ab0d9479fd306905bd6d61b8cf8becd9a40bdcf9b03542e8267c644ef19f03f44bfca0bc461'
            'ae33d8f19ba3aa131343a4027f54bfb08fd1847280ed19eb9c9b3e781020ecdb31e96bc51e06f837883a958f384ce6513999296d4140a90ca8b0248accb703a1')

prepare() {
  cd "$_pkgname-$pkgver"

  patch -p2 < ../certs.py.patch

  find . -name '*.py' |
    xargs sed -i -e 's|/usr/bin/env python|/usr/bin/env python2|' \
    -e 's|/usr/bin/python|/usr/bin/python2|'
}

build() {
  cd "$_pkgname-$pkgver"

  python2 setup.py build
}

package() {
  cd "$_pkgname-$pkgver"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

